﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using HYRevitCode.FormUtility.ModelessFormControlSuite.ControlLayer;
using HYRevitCode.FormUtility.ModelessFormControlSuite.ModelLayer;
using HYRevitCode.FormUtility.ModelessFormControlSuite.ViewLayer;

namespace AdjustInstallationHeight
{
	internal class LoopMangerNoneSwitch : BaseLoopMangerNoneSwitch
	{
		public LoopMangerNoneSwitch(UIDocument inputUiDoc, IModelessFormNoneSwitch inputForm, List<FormStructure> lstFormData, IWin32Window inputParentHandle = null, PickObjectMethod inputPickMethod = null) : base(inputUiDoc, inputForm, inputParentHandle, inputPickMethod)
		{
			this.m_uiDoc = inputUiDoc;
			this.m_form = inputForm;
			this.m_lstFormData = lstFormData;
			this.DoBeforeContinue();
		}

		protected override void DoAfterPick(object inputValue)
		{
			ElementMoveOperator.MoveElement(this.m_uiDoc, this.m_beamAndFloorSearcher, this.m_form as BaseNoneSwitchForm, this.m_lstFormData, inputValue as ElementNeedMoveAnalyzer);
		}

		protected override void DoBeforeContinue()
		{
			if (this.m_useForm is OverallForm)
			{
				this.m_lstSelectCategory = (this.m_useForm as OverallForm).LstBuiltInCategory;
			}
			else if (this.m_useForm is BranchForm)
			{
				this.m_lstSelectCategory = (this.m_useForm as BranchForm).LstBuiltInCategory;
			}
			this.m_usePickObjectMethod = new PickObjectMethod(this.GetNowAnalyzer);
		}

		private ElementNeedMoveAnalyzer GetNowAnalyzer()
		{
			return new ElementNeedMoveAnalyzer(this.m_uiDoc, this.m_lstSelectCategory);
		}

		private UIDocument m_uiDoc;

		private IModelessFormNoneSwitch m_form;

		private BeamAndFloorSearcher m_beamAndFloorSearcher;

		private List<FormStructure> m_lstFormData;

		private List<BuiltInCategory> m_lstSelectCategory = new List<BuiltInCategory>();
	}
}
